home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / pascal / totsrc11.zip / TOTIO3.PAS < prev    next >
Pascal/Delphi Source File  |  1993-05-04  |  33KB  |  1,128 lines

  1. {               Copyright 1991 TechnoJock Software, Inc.               }
  2. {                          All Rights Reserved                         }
  3. {                         Restricted by License                        }
  4.  
  5. {                             Build # 1.10                             }
  6.  
  7. Unit totIO3;
  8. {$I TOTFLAGS.INC}
  9.  
  10. {
  11.  Development Notes:
  12.           5/23/91   1.00a    Added reaction to Mouse method 1
  13.           5/29/91   1.00b    Corrected DEL when no chars in list
  14.           7/23/91   1.00c    Corrected DEL when empty lines
  15.           2/06/91   1.00d    Adjusted cursor when list/array assigned
  16.           10/02/92  1.00e    Corrected backspace on empty linked list
  17. }
  18.  
  19. INTERFACE
  20.  
  21. uses DOS, CRT,
  22.      totSYS, totLOOK, totFAST, totSTR, totINPUT, totLINK, totIO1;
  23.  
  24. TYPE
  25.  
  26. pWordwrapIOOBJ = ^WordwrapIOOBJ;
  27. WordwrapIOOBJ = object(MultiLineIOOBJ)
  28.    vTopLine: integer;         {number of first line in window}
  29.    vTotLines: integer;        {total number of lines}
  30.    vListAssigned: boolean;    {is data assigned}
  31.    vScrollBarOn: boolean;     {is the vertical scrollbar required}
  32.    vBoxBorder: boolean;       {is the data enclosed in a box}
  33.    vCursorX: byte;            {position of cursor in Str}
  34.    vCursorY: byte;            {line no. of cursor - from top}
  35.    vMaxLines: integer;        {limit on total number of lines}
  36.    vLineStr: string;          {copy of line being edited}
  37.    vInsert: boolean;          {is field initially in insert mode}
  38.    vWidth: byte;              {maximum width of an input string}
  39.    vEndKey: word;             {key to jump to next field}
  40.    vAllowEdit: boolean;       {can user change the text}
  41.    {methods ...}
  42.    constructor Init(X1,Y1,width,lines:byte;Title:string);
  43.    procedure   WriteLine(OffSet:integer;Status:tStatus);
  44.    procedure   SetEndKey(K:word);
  45.    procedure   SetAllowEdit(On:boolean);
  46.    procedure   DisplayAllLines(Status:tStatus);
  47.    procedure   RefreshScrollBar(Status:tStatus);
  48.    procedure   MoveCursor;
  49.    procedure   CursorJump(Line:integer);
  50.    procedure   CursorUp;
  51.    procedure   CursorDown;
  52.    procedure   CursorLeft;
  53.    procedure   CursorRight;
  54.    procedure   CursorPgUp;
  55.    procedure   CursorPgDn;
  56.    procedure   CursorHome;
  57.    procedure   CursorEnd;
  58.    procedure   CursorTop;
  59.    procedure   CursorBottom;
  60.    procedure   DeleteChar;
  61.    procedure   Backspace;
  62.    procedure   ProcessEnter;
  63.    function    GetNextLinesLeadingSpaces(var StrOne,StrTwo: string;var LastLine: boolean): byte;
  64.    procedure   GetNextLinesFullWords(var StrOne,StrTwo: string;var LastLine: boolean;Line:integer);
  65.    procedure   PushWordsToNextLine(var StrOne,StrTwo: string;var LastLine: boolean;Line:integer);
  66.    procedure   WrapFrom(Line: integer);
  67.    procedure   AdjustMouseKey(var InKey: word;X,Y:byte);
  68.    procedure   MouseChoose(X,Y:byte);
  69.    procedure   ProcessChar(Ch:char);
  70.    procedure   SetIns(InsOn:boolean);
  71.    procedure   WrapFull;                                    VIRTUAL;
  72.    function    Select(K:word; X,Y:byte):tAction;            VIRTUAL;
  73.    function    ProcessKey(InKey:word;X,Y:byte):tAction;     VIRTUAL;
  74.    procedure   Display(Status:tStatus);                     VIRTUAL;
  75.    function    Suspend:boolean;                             VIRTUAL;
  76.    function    GetString(Line:integer): string;             VIRTUAL;
  77.    procedure   SetString(Line:integer;Str: string);         VIRTUAL;
  78.    procedure   DeleteLine(Line:integer);                    VIRTUAL;
  79.    procedure   InsertLine(Line:integer);                    VIRTUAL;
  80.    procedure   InsertAction(InsOn:boolean);                 VIRTUAL;
  81.    destructor  Done;                                        VIRTUAL;
  82. end;
  83.  
  84. pWWArrayIOOBJ = ^WWArrayIOOBJ;
  85. WWArrayIOOBJ = object (WordwrapIOOBJ)
  86.    vArrayPtr: pointer;
  87.    vStrLength: byte;
  88.    {methods ...}
  89.    constructor Init(X1,Y1,width,lines:byte;Title:string);
  90.    procedure   AssignList(var StrArray; Total:Longint; StrLength:byte);
  91.    function    GetString(Line:integer): string;             VIRTUAL;
  92.    procedure   SetString(Line:integer;Str: string);         VIRTUAL;
  93.    procedure   DeleteLine(Line:integer);                    VIRTUAL;
  94.    procedure   InsertLine(Line:integer);                    VIRTUAL;
  95.    destructor  Done;                                        VIRTUAL;
  96. end; {WWArrayIOOBJ}
  97.  
  98. pWWLinkIOOBJ = ^WWLinkIOOBJ;
  99. WWLinkIOOBJ = object (WordwrapIOOBJ)
  100.    vLinkList: ^StrDLLOBJ;
  101.    vWrapping: boolean;
  102.    {methods ...}
  103.    constructor Init(X1,Y1,width,lines:byte;Title:string);
  104.    procedure   AssignList(var LinkList: StrDLLOBJ; Max:integer);
  105.    procedure   WrapFull;                                    VIRTUAL;
  106.    function    GetString(Line:integer): string;             VIRTUAL;
  107.    procedure   SetString(Line:integer;Str: string);         VIRTUAL;
  108.    procedure   DeleteLine(Line:integer);                    VIRTUAL;
  109.    procedure   InsertLine(Line:integer);                    VIRTUAL;
  110.    destructor  Done;                                        VIRTUAL;
  111. end; {WWLinkIOOBJ}
  112.  
  113. procedure IO3Init;
  114.  
  115. IMPLEMENTATION
  116. {||||||||||||||||||||||||||||||||||||||||||||}
  117. {                                            }
  118. {     W W F i e l d O B J   M E T H O D S    }
  119. {                                            }
  120. {||||||||||||||||||||||||||||||||||||||||||||}
  121. constructor WordwrapIOOBJ.Init(X1,Y1,width,lines:byte;Title:string);
  122. {}
  123. begin
  124.    MultiLineIOOBJ.Init(X1,Y1,width,lines,Title);
  125.    vTopLine := 1;
  126.    vTotLines := 0;
  127.    vListAssigned := false;
  128.    vScrollBarOn := false;
  129.    vCursorX := 1;
  130.    vCursorY := 1;
  131.    vInsert := IOTOT^.InputIns;
  132.    vEndKey := 324; {F10}
  133.    vAllowEdit := true;
  134. end; {WordwrapIOOBJ.Init}
  135.  
  136. procedure WordwrapIOOBJ.SetEndKey(K:word);
  137. {}
  138. begin
  139.    vEndKey := K;
  140. end; {WordwrapIOOBJ.SetEndKey}
  141.  
  142. procedure WordwrapIOOBJ.SetAllowEdit(On:boolean);
  143. {}
  144. begin
  145.    vAllowEdit := On;
  146. end; {WordwrapIOOBJ.SetAllowEdit}
  147.  
  148. procedure WordwrapIOOBJ.WriteLine(OffSet:integer;Status:tStatus);
  149. {}
  150. var 
  151.   Str : string;
  152.   A: byte;
  153. begin
  154.    if vListAssigned then
  155.    begin
  156.       Str := GetString(pred(vTopLine)+OffSet);
  157.       Case Status of
  158.          HiStatus: A := IOTOT^.FieldCol(2);
  159.          Norm: A := IOTOT^.FieldCol(1);
  160.          else A := IOTOT^.FieldCol(4);
  161.       end; {case}
  162.       Screen.WriteAT(vBorder.X1,vBorder.Y1+pred(Offset),A,
  163.                      padleft(Str,vBorder.X2-vBorder.X1,' '));
  164.    end;
  165. end; {WordwrapIOOBJ.WriteLine}
  166.  
  167. procedure WordwrapIOOBJ.DisplayAllLines(Status:tStatus);
  168. {}
  169. var I: integer;
  170. begin
  171.    for I := 1 to vRows do
  172.        WriteLine(I,Status);
  173.    if vCursorX > length(vLineStr) then
  174.       CursorEnd
  175.    else
  176.       MoveCursor;
  177. end; {WordwrapIOOBJ.DisplayAllLines}
  178.  
  179. function WordwrapIOOBJ.Select(K:word; X,Y:byte): tAction;
  180. {}
  181. begin
  182.    vScrollBarOn := (vTotLines > vRows);
  183.    Display(HiStatus);
  184.    WriteMessage;
  185.    MoveCursor;
  186.    Select := none;
  187. end; {WordwrapIOOBJ.Select}
  188.  
  189. procedure WordwrapIOOBJ.MoveCursor;
  190. {}
  191. begin
  192.    Screen.GotoXY(pred(vBorder.X1+vCursorX),pred(vBorder.Y1+vCursorY));
  193. end; {WordwrapIOOBJ.MoveCursor}
  194.  
  195. procedure WordwrapIOOBJ.CursorJump(Line:integer);
  196. {}
  197. var
  198.   Tot: integer;
  199. begin
  200.    Tot := vBorder.Y2 - succ(vBorder.Y1);
  201.    Line := Line - vBorder.Y1;
  202.       if vTotLines <= vRows then  {all Lines on display}
  203.       begin
  204.          SetString(pred(vTopLine)+vCursorY,vLineStr);
  205.          vCursorY := (Line * vTotLines) div Tot;
  206.          vLineStr := GetString(pred(vTopLine)+vCursorY);
  207.          CursorHome;
  208.          MoveCursor;
  209.       end
  210.       else
  211.       begin
  212.          SetString(pred(vTopLine)+vCursorY,vLineStr);
  213.          vTopLine := (Line * vTotLines) div Tot;
  214.          vCursorY := 1;
  215.          vCursorX := 1;
  216.          MoveCursor;
  217.          vLineStr := GetString(pred(vTopLine)+vCursorY);
  218.          DisplayAllLines(HiStatus);
  219.       end;
  220. end; {WordwrapIOOBJ.Cursor}
  221.  
  222. procedure WordwrapIOOBJ.CursorUp;
  223. {}
  224. begin
  225.    if vCursorY = 1 then
  226.    begin
  227.       if vTopLine > 1 then
  228.       begin
  229.          SetString(vTopLine,vLineStr);
  230.          dec(vTopLine);
  231.          vLineStr := GetString(vTopLine);
  232.          DisplayAllLines(HiStatus);
  233.       end;
  234.    end
  235.    else
  236.    begin